package abs_factory

import "fmt"

type IPlatformApiFactory interface {
	CreateOrderListApi() IOrderApi
	CreateOrderDetailApi() IOrderDetailApi
}

type IShopMange interface {
	GetShop() *Shop
	SetShop(shop *Shop)
}

type shopManger struct {
	shop *Shop
}

func (sm *shopManger) GetShop() *Shop {
	return sm.shop
}

func (sm *shopManger) SetShop(shop *Shop) {
	sm.shop = shop
}

type IOrderApi interface {
	GetOrderList(page int, limit int, params map[string]any)
}
type IOrderDetailApi interface {
	GetOrderDetail(code string)
}

type tmallOrderApi struct {
	sm shopManger
}

func (toa *tmallOrderApi) GetOrderList(page int, limit int, params map[string]any) {
	fmt.Println("天猫查询订单")
}

type tmallOrderDetailApi struct {
	sm shopManger
}

func (toda *tmallOrderDetailApi) GetOrderDetail(code string) {
	fmt.Println("天猫查询订单详情")
}

type douyinOrderApi struct {
	sm shopManger
}

func (doi *douyinOrderApi) GetOrderList(page int, limit int, params map[string]any) {
	fmt.Println("抖音查询订单")
}

type douyinOrderDetailApi struct {
	sm shopManger
}

func (doda *douyinOrderDetailApi) GetOrderDetail(code string) {
	fmt.Println("抖查询订单详情")
}

type tmallPlatformApiFactory struct {
}

func (tpaf *tmallPlatformApiFactory) CreateOrderListApi() IOrderApi {
	return &tmallOrderApi{}
}
func (tpaf *tmallPlatformApiFactory) CreateOrderDetailApi() IOrderDetailApi {
	return &tmallOrderDetailApi{}
}

type douyinPlatformApiFactory struct {
}

func (dpaf *douyinPlatformApiFactory) CreateOrderListApi() IOrderApi {
	return &douyinOrderApi{}
}
func (dpaf *douyinPlatformApiFactory) CreateOrderDetailApi() IOrderDetailApi {
	return &douyinOrderDetailApi{}
}

type Shop struct {
	ShopId   int
	ShopName string
	PlatForm string
}

func NewPlatApi(shop *Shop) IPlatformApiFactory {
	switch shop.PlatForm {
	case "tmall":
		return &tmallPlatformApiFactory{}
	case "douyin":
		return &douyinPlatformApiFactory{}
	default:
		panic("类型不存在")
	}
}
